#ifndef XMLTREE_H
#define XMLTREE_H

#include <iostream>
#include <list>
#include <map>

using namespace  std;

class XMLTree;

typedef std::string XName;
typedef std::string XValue;
typedef std::list<XName> KeyList;
typedef std::list<XValue> ValuesList;
typedef std::list<XMLTree*> ChildList;

class XMLTag{
public:
    static std::string Open(const std::string& name){
        std::string s;
        s.append("<");
        s.append(name);
        s.append(">");
        return s;
    }

    static std::string End(const std::string& name){
        std::string s;
        s.append("</");
        s.append(name);
        s.append(">");
        return s;
    }
};

class XMLTree
{
public:
    XMLTree();
    XMLTree(XName);
    XMLTree(XName,XValue);
    virtual ~XMLTree();

    XName rootNode() const;
    //Add empty subtree.
    void add(XName);
    //Add element to current tree.
    void add(XName,XValue);
    //Add tree.
    void add(XMLTree&);
    friend ostream& operator << (ostream&, const XMLTree& );
private:
    KeyList *keys;
    ValuesList *values;
    XName nodeName;
    ChildList *child;
    XMLTree *parent;
};

#endif // XMLTREE_H
